﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HousingDistribution
{
    public partial class FormSetCheckinTime : Form
    {
        public FormSetCheckinTime(int idhousing, FormPersonDetailsNoHousingTab.UpdateCheckintimeDelegete updateCheckintime)
        {
            InitializeComponent();

            this.idhousing = idhousing;
            this.updateCheckintime = updateCheckintime;
            
            dateTextBoxCheckinTime.Text = DateTime.Now.ToShortDateString();
        }

        private DateTime setCheckintime()
        {
            if (dateTextBoxCheckinTime.Text != "--")
                return this.dateProc.Parse(dateTextBoxCheckinTime.Text);

            return DateTime.Now;
        }

        private void buttonSave_Click(object sender, EventArgs e)
        {
            updateCheckintime(this.idhousing, setCheckintime());
            this.Close();
        }
        
        private void buttonClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private int idhousing;
        DateProc dateProc = new DateProc("YY-MM-DD");
        FormPersonDetailsNoHousingTab.UpdateCheckintimeDelegete updateCheckintime;
    }
}
